package com.example.musicrunner.media;

import java.util.ArrayList;
import java.util.HashMap;
import java.io.File;
import java.io.FilenameFilter; 

public class PathManager {
  
    private ArrayList<HashMap<String, String>> songsList = new ArrayList<HashMap<String, String>>();
 
    public PathManager() {
    	//TODO
    }  
     
    class FileExtensionFilter implements FilenameFilter {
        public boolean accept(File dir, String name) {
            return (name.endsWith(".mp3") || name.endsWith(".MP3"));
        }
    }
 
    public ArrayList<HashMap<String, String>> getPlayList(){
        File card = new File("/sdcard/");
        if (card.listFiles(new FileExtensionFilter()).length > 0) {
            for (File file : card.listFiles(new FileExtensionFilter())) {
                HashMap<String, String> song = new HashMap<String, String>();
                song.put("songTitle", file.getName().substring(0, (file.getName().length() - 4)));
                song.put("songPath", file.getPath());
                songsList.add(song);
            }
        }
        return songsList;
    }

 
}